home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / bcfamily / source / setvect.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-12  |  2.4 KB  |  84 lines

  1. //
  2. //      *******************************************************************
  3. //        JdeBP C++ Library Routines          General Public Licence v1.00
  4. //            Copyright (c) 1991,1992     Jonathan de Boyne Pollard
  5. //      *******************************************************************
  6. //
  7. // Part of FamAPI.LIB
  8. //
  9.  
  10. #include "famapi.h"
  11. #include "dosdos.h"
  12.  
  13. //
  14. //    The function chain invoked by a vector handler starts at the latest
  15. //    setting of DosSetVect() and *may* chain through to NoFunction() .
  16. //
  17. static int _APICALL NoFunction () { return 0 ; }
  18.  
  19. static int (_APICALL *Int0Function)() = NoFunction ;
  20. static int (_APICALL *Int4Function)() = NoFunction ;
  21. static int (_APICALL *Int5Function)() = NoFunction ;
  22. static int (_APICALL *Int6Function)() = NoFunction ;
  23. static int (_APICALL *Int7Function)() = NoFunction ;
  24. static int (_APICALL *Int10Function)() = NoFunction ;
  25.  
  26. //
  27. //    The actual hardware interrupt handlers invoke the vector call chains.
  28. //
  29. static void interrupt Int0Handler() { (*Int0Function)() ; }
  30. static void interrupt Int4Handler() { (*Int4Function)() ; }
  31. static void interrupt Int5Handler() { (*Int5Function)() ; }
  32. static void interrupt Int6Handler() { (*Int6Function)() ; }
  33. static void interrupt Int7Handler() { (*Int7Function)() ; }
  34. static void interrupt Int10Handler() { (*Int10Function)() ; }
  35.  
  36. //
  37. //    Set exception vectors
  38. //
  39. USHORT _APICALL
  40. DosSetVec    ( USHORT VectNum,
  41.              int (_APICALL *Function)(),
  42.              int (_APICALL * far *PrevFunction)() )
  43. {
  44.     if (VectNum != 0
  45.     &&  VectNum != 4 && VectNum != 5 && VectNum != 6
  46.     &&  VectNum != 7 && VectNum != 0x10 )
  47.         return ERROR_NOT_SUPPORTED ;
  48.  
  49.     DosDosSaveVectors() ;
  50.     switch (VectNum) {
  51.         case 0:
  52.             *PrevFunction = Int0Function;
  53.             Int0Function = Function ;
  54.             DosDosSetVect( VectNum, Int0Handler) ;
  55.             break;
  56.         case 4:
  57.             *PrevFunction = Int4Function;
  58.             Int4Function = Function ;
  59.             DosDosSetVect( VectNum, Int4Handler) ;
  60.             break;
  61.         case 5:
  62.             *PrevFunction = Int5Function;
  63.             Int5Function = Function ;
  64.             DosDosSetVect( VectNum, Int5Handler) ;
  65.             break;
  66.         case 6:
  67.             *PrevFunction = Int6Function;
  68.             Int6Function = Function ;
  69.             DosDosSetVect( VectNum, Int6Handler) ;
  70.             break;
  71.         case 7:
  72.             *PrevFunction = Int7Function;
  73.             Int7Function = Function ;
  74.             DosDosSetVect( VectNum, Int7Handler) ;
  75.             break;
  76.         case 0x10:
  77.             *PrevFunction = Int10Function;
  78.             Int10Function = Function ;
  79.             DosDosSetVect( VectNum, Int10Handler) ;
  80.             break;
  81.     }
  82.     return NO_ERROR ;
  83. }
  84.